clc;

x1n = cos(0.25*pi*n);
x2n = sin(1/8*pi*n);

x1_nk = cos(0.25*pi*(n-k));
x2_nk = sin(1/8*pi*(n-k));
xn = x1n + j*x2n;
x_nk = x1_nk + j*x2_nk;

% 算DFT
Xk = WN(N,xn);
X_Nk = WN(N-k,x_nk);

X1k = (Xk+conj(Xk))/2
X2k = (Xk-conj(Xk))/2*j
figure(1)
stem(k,X1k);
figure(2)
stem(k,X2k);

function Xk = WN(N,xn)
N = 8;
n = 0:N-1;
k = 0:N-1;

WN = exp(-j*2*pi/N);
nk = n'*k;
WNnk = WN.^nk;
Xk = xn * WNnk;
end